Skip to content

Scoped contexts and a proper precompilation workload#62

Open
JamesWrigley wants to merge 4 commits intomasterfrom
precompile
Open

Scoped contexts and a proper precompilation workload#62
JamesWrigley wants to merge 4 commits intomasterfrom
precompile

Conversation

@JamesWrigley
Copy link
Copy Markdown
Collaborator

Following on from #61 and #58, this PR:

  • Moves the global ContextCluster state into a ScopedValue. Since accessing ScopedValue's can allocate I tried to minimize accesses in hot paths (like serialization and message handling) by assigning the value to a local variable.
  • Adds support for in-process workers to LocalManager.
  • Uses the above two features to start both a master and worker in the same process for precompilation.

Scoped contexts could potentially be exposed as an API and used for multi-cluster support. The TTFW (Time-To-First-Worker) for addprocs(1) dropped from ~1.8s to ~1s on Julia 1.12, and subsequent calls take ~0.8s.

For reviewers, I've tried to keep each commit atomic so I'd recommend reviewing them one-by-one.

This prevents a lingering task during precompilation.
@JamesWrigley JamesWrigley requested a review from jpsamaroo March 29, 2026 00:50
@JamesWrigley JamesWrigley self-assigned this Mar 29, 2026
@JamesWrigley JamesWrigley added the enhancement New feature or request label Mar 29, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 29, 2026

Codecov Report

❌ Patch coverage is 93.75000% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.65%. Comparing base (d548dee) to head (311f2ed).

Files with missing lines Patch % Lines
src/cluster.jl 91.80% 10 Missing ⚠️
src/remotecall.jl 91.66% 2 Missing ⚠️
src/DistributedNext.jl 95.00% 1 Missing ⚠️
src/process_messages.jl 94.44% 1 Missing ⚠️
src/workerpool.jl 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #62      +/-   ##
==========================================
+ Coverage   88.39%   88.65%   +0.25%     
==========================================
  Files          12       13       +1     
  Lines        2232     2283      +51     
==========================================
+ Hits         1973     2024      +51     
  Misses        259      259              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This makes use of the scoped context and in-process worker support to have both
the master and worker running in the same process for precompilation.

Also lowered the sleep time for the launch Condition notification to 0.1s. This
helps since the Condition is edge-triggered and launching an in-process worker
usually takes less than 1s.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant